<template>
	<sc-drawer
		v-model="visible"
		title="添加班级"
		size="700px"
		@cancel="$emit('close')"
		@confirm="confirm"
	>
		<classForm ref="courseFormRef" />
	</sc-drawer>
</template>

<script setup>
import { ref, getCurrentInstance } from "vue";
import { ElMessage } from "element-plus";
import classForm from "@/views/teach/course/class-form/index.vue";
const { proxy } = getCurrentInstance();
const courseFormRef = ref(null);
const visible = ref(true);

async function confirm() {
	const params = {
		...courseFormRef.value.classFormState,
	};
	delete params.classHoursList;

	const { code, msg, message } = await proxy.$API.course.addClassGrade.post(
		params
	);
	if (code && code === 200) {
		ElMessage({
			message: msg,
			type: "success",
		});
		visible.value = false;
	} else {
		ElMessage({
			message: msg || message,
			type: "error",
		});
	}
}
</script>

<style lang="scss" scoped>
.mr10 {
	margin-right: 10px;
}
</style>
